let app = getApp();
let httptool = require("../../../utils/zry.httptool.js");
Page({
  data:{
    customer: { Content: '', Tel:'',},
    msgprop:'',//消息提示 
  },
  onLoad:function(options){
    // 页面初始化 options为页面跳转所带来的参数
  },
  telChange:function(e){
    this.data.customer.Tel = e.detail.value;
    this.setData({ customer: this.data.customer});
  },
  charChange:function(e){
    this.data.customer.Content = e.detail.value;
    this.setData({ customer: this.data.customer});
  },
  feedBtn:function(){
    let that=this;
    let content = app.trim(that.data.customer.Content);
    if (content==""){
      app.showNotify(that, "反馈内容不能为空！");
      return false;
    } else if (content.length < 12) {
      app.showNotify(that, "反馈内容不能少于12个字！");
      return false;
    }
    let tel = app.trim(that.data.customer.Tel);
    if(tel==""){
      app.showNotify(that, "手机号码不能为空！");
      return false;
    }
    if (!app.validate(tel, 'phone')) {
      app.showNotify(that, "手机号码格式不对");
      return false;
    }

    let param={};
    param.Content=that.data.customer.Content;
    param.customerId =app.getStorage('customerId') || '0';
    param.Tel=that.data.customer.Tel;
    
    httptool.ajaxPost("api/Feedback/AddFeedback", param,function(res){
      if(res.suc){
        wx.redirectTo({
            url: '/pages/feedresult/feedresult?type='+2,
          })
      }else{
        app.showNotify(that, res.msg);
      }
    });
  }
})